package cn.tedu.jsd2210.csmall.passport.service.impl;

import cn.tedu.jsd2210.csmall.passport.ex.ServiceException;
import cn.tedu.jsd2210.csmall.passport.mapper.AdminMapper;
import cn.tedu.jsd2210.csmall.passport.mapper.AdminRoleMapper;
import cn.tedu.jsd2210.csmall.passport.mapper.RoleMapper;
import cn.tedu.jsd2210.csmall.passport.pojo.dto.AdminAddNewDTO;
import cn.tedu.jsd2210.csmall.passport.pojo.dto.AdminLoginInfoDTO;
import cn.tedu.jsd2210.csmall.passport.pojo.entity.Admin;
import cn.tedu.jsd2210.csmall.passport.pojo.entity.AdminRole;
import cn.tedu.jsd2210.csmall.passport.pojo.vo.AdminListItemVO;
import cn.tedu.jsd2210.csmall.passport.pojo.vo.RoleListItemVO;
import cn.tedu.jsd2210.csmall.passport.security.AdminDetails;
import cn.tedu.jsd2210.csmall.passport.service.IAdminService;
import cn.tedu.jsd2210.csmall.passport.service.IRoleService;
import cn.tedu.jsd2210.csmall.passport.web.ServiceCode;
import com.alibaba.fastjson.JSON;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 处理角色数据的业务实现类
 *
 * @author java@tedu.cn
 * @version 0.0.1
 */
@Slf4j
@Service
public class RoleServiceImpl implements IRoleService {
    @Autowired
    private RoleMapper roleMapper;

    public RoleServiceImpl() {
        log.debug("创建业务类对象：RoleServiceImpl");
    }

    @Override
    public List<RoleListItemVO> list() {
        log.debug("开始处理[查询管理员列表]的业务,无参数");
        List<RoleListItemVO> list= roleMapper.list();
        Iterator<RoleListItemVO> iterator = list.iterator();
        while (iterator.hasNext()){
            RoleListItemVO item=iterator.next();
            if(item.getId()==1){
                iterator.remove();
                break;
            }
        }
        return list;
    }
}
